<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- data.js -->
    <script>
        var data = [{
            content: '测试文字',
            url: '',
            num: 25,
            description: '描述信息',
        },
        {
            content: 'flv.js 中文API文档',
            url: 'https://www.jianshu.com/p/b58356b465c4',
            num: 33,
            description: '',
        },
        ]
    </script>
    <style>
        *,
        body {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            display: flex;
            flex-direction: column;
            height: 100vh;
            background-size: cover;
            background-color: rgba(128, 128, 128, .8);
            padding: 0 10px;
            color: lavender;
        }

        ul,
        ol,
        li {
            list-style: none;
        }

        a {
            text-decoration: none;
            color: lavender;
        }

        a:hover {
            color: RoyalBlue;
        }

        footer {
            position: absolute;
            bottom: 0px;
            left: 50%;
            transform: translate(-50%);
        }

        .row {
            display: flex;
            /* 源代码里面没有自动换行 */
            flex-wrap: wrap;
            width: 100%;
            margin-left: -8px;
            margin-right: -8px;
            color: lavender;
        }

        /* 不能设置row.a.hover会失效.一定要的话,再加下hover */

        .row__cell {
            /* 设置单元格大小 */
            /* width不用设置，用了flex */
            height: 100px;

            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            gap: 5px;
            letter-spacing: 1px;

            /* 上右下左 */
            margin: 8px 8px 8px 8px;


            padding-left: 8px;
            padding-right: 8px;
            border-radius: 20px;
            border-top: 1px solid rgba(255, 255, 255, .5);
            border-left: 1px solid rgba(255, 255, 255, .5);
            border-bottom: 1px solid rgba(255, 255, 255, .2);
            border-right: 1px solid rgba(255, 255, 255, .2);
            backdrop-filter: blur(10px);
            background: rgba(50, 50, 50, .2);
        }

        .row__cell .content {
            font-size: 24px;
        }

        .row__cell .description {
            font-size: 12px;
        }

        /* 用于填充的盒子 */
        .row__cell--fill {
            flex: 1;
        }

        /* 设置固定盒子大小，25%可以替换成想要的大小 */
        .row__cell--box {
            flex: 0 0 var(--num);
        }
    </style>
</head>

<body>
    <div class="box">
        <!-- Row -->
        <div class="row">
            <!--Cell with given width. Replace 25% with whatever you want -->
            <div class="row__cell row__cell" style="--num:25%">
                测试文字
            </div>
        </div>



    </div>

    <footer style="text-align: center;">
        &copy; :·.
    </footer>
    <!-- render.js -->
    <script>
        window.addEventListener('DOMContentLoaded', () => {
    function htmlRender() {
        var row = document.querySelector('.row')
        row.innerHTML = '';
        var row_text = ''
        data.forEach((item, index) => {
            var str = `        
            ${(index+1) % 3 == 0 ? `<div class="row__cell row__cell--fill">` : `<div class="row__cell row__cell--box" style="--num:${item.num}%">`}
            <p class="content">${item.url ? `<a href=${item.url}>${item.content}</a>` : item.content}</p>
            <p class = "description">${item.description ? item.description : '&nbsp;'}</p>
            </div>
    `;
            row_text += str
        })
        row.innerHTML = row_text
    }
    function init() {
        htmlRender()
    }
    init()
})

    </script>
</body>

</html>